<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));

if((($_FILES["file"]["type"]=="image/gif")
    ||($_FILES["file"]["type"] == "image/jpeg")
    ||($_FILES['file']['type']=="image/png")
    ||($_FILES['file']['type']=="image/pjpeg"))
    && ($_FILES["file"]["size"] < 20000)
    && in_array($extension, $allowedExts))
{
    if ($_FILES["file"]["error"] > 0)
    {
        echo "Eroor :".$_FILES["file"]["error"];
    }
    else
    {
        echo "Upload:".$_FILES["file"]["name"];
        echo "Type: " . $_FILES["file"]["type"] . "<br />";
        echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo "Stored in: " . $_FILES["file"]["tmp_name"];
    }
}
 else 
     {
        echo "Invalid file";
     }

?>
